package org.jeecg.controller;

import org.jeecg.domain.Activity;
import org.jeecg.domain.Coupon;
import org.jeecg.domain.dto.AddDto;
import org.jeecg.domain.dto.FindDto;
import org.jeecg.service.ActivityService;
import org.jeecg.service.CouponService;
import org.jeecg.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/coupon")
public class CouponController {
    @Autowired
    private CouponService couponService;
    @Autowired
    private ActivityService activityService;
    @PostMapping("/findAll")
    public ResponseResult findAll(@RequestBody FindDto findDto){
        return couponService.findAll(findDto);
    }
    @PostMapping("/deleteOne")
    public ResponseResult deleteOne(@RequestParam("id") String id){
        return couponService.deleteOne(id);
    }
    @GetMapping("/findActicity")
    public ResponseResult findActicity(){
        List<Activity> list = activityService.list();
        return ResponseResult.okResult(list);
    }
    @PostMapping("/addCoupon")
    public ResponseResult addCoupon(@RequestBody AddDto addDto){
        return couponService.addCoupon(addDto);
    }
    @PostMapping("/updCoupon")
    public ResponseResult updCoupon(@RequestBody Coupon coupon){
        return couponService.updCoupon(coupon);
    }
}
